<script setup>
import SubWrap from './pages/wrap.vue'
import { ref, onMounted } from 'vue';
import useStoreIndex from './store/modules/index';
import { storeToRefs } from "pinia";
import { fRequest } from './api/request.js'
import { ElLoading } from 'element-plus';

let oStore = useStoreIndex();//

let bShowLoading = null;
const fLoading = () => {
  bShowLoading = ElLoading.service({
    target: '#app',
    lock: true,
    text: 'Loading',
    body: true,
    background: 'rgba(0, 0, 0, 0.7)',
  })
}

// 请求用户信息
async function fRequestUserInfo() {
  let res = await fRequest({
    url: '/api/getUserInfo',
    method: 'get',
  })
  oStore.fSetUserInfo({ ...res.data });
};
// 请求左侧菜单
async function fRequestMenuTree() {
  let res = await fRequest({
    url: '/api/getMenuTree',
    method: 'get',
  })
  if (res.data.menulist) {
    bShowLoading.close();
    oStore.fSetMuenList(res.data.menulist);
  }
}


onMounted(() => {
  // fLoading();
  fRequestUserInfo();// 请求用户信息
  // fRequestMenuTree();// 请求左侧菜单
})
console.log(import.meta.env);
</script>

<template>
  <div class="">
    <sub-wrap></sub-wrap>
  </div>
</template>

<style scoped lang="less"></style>
